let height = [1,8,6,2,5,4,8,3,7]

let maxArea = function(height){
    let left = 0;
    let right = height.length - 1;
    let max = 0
    while(left < right){
        if(height[left] < height[right]){
            left++
        }else{
            right--
        }
        let temp = Math.min(height[left], height[right]) * (right - left)
        max = Math.max(max, temp)
    }
    return max
}

console.log(maxArea(height))